Skip to content

ext/pgsql: pgsql_copy_from to support iterable. #16124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

devnexen
Copy link
Member

inspired from the Pdo\Pgsql new feature GH-15893.

inspired from the Pdo\Pgsql new feature phpGH-15893.
@devnexen devnexen force-pushed the pgsql_copy_from_iterable branch from 7dd144c to 1eef6df Compare September 30, 2024 12:22
@devnexen devnexen marked this pull request as ready for review September 30, 2024 12:24
@devnexen devnexen requested review from Girgias and removed request for kocsismate September 30, 2024 12:24
@@ -3376,7 +3400,7 @@ PHP_FUNCTION(pg_copy_from)
ZEND_PARSE_PARAMETERS_START(3, 5)
Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
Z_PARAM_PATH_STR(table_name)
Z_PARAM_ARRAY(pg_rows)
Z_PARAM_ARRAY_OR_OBJECT(pg_rows)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Z_PARAM_ITERABLE

}
} ZEND_HASH_FOREACH_END();
} else {
zend_object_iterator *iter = Z_OBJ_P(pg_rows)->ce->get_iterator(Z_OBJCE_P(pg_rows), pg_rows, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
zend_object_iterator *iter = Z_OBJ_P(pg_rows)->ce->get_iterator(Z_OBJCE_P(pg_rows), pg_rows, 0);
zend_object_iterator *iter = Z_OBJCE_P(pg_rows)->get_iterator(Z_OBJCE_P(pg_rows), pg_rows, 0);

@@ -847,7 +847,7 @@ function pg_put_line($connection, string $query = UNKNOWN): bool {}
*/
function pg_copy_to(PgSql\Connection $connection, string $table_name, string $separator = "\t", string $null_as = "\\\\N"): array|false {}

function pg_copy_from(PgSql\Connection $connection, string $table_name, array $rows, string $separator = "\t", string $null_as = "\\\\N"): bool {}
function pg_copy_from(PgSql\Connection $connection, string $table_name, array|object $rows, string $separator = "\t", string $null_as = "\\\\N"): bool {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function pg_copy_from(PgSql\Connection $connection, string $table_name, array|object $rows, string $separator = "\t", string $null_as = "\\\\N"): bool {}
function pg_copy_from(PgSql\Connection $connection, string $table_name, array|Traversable $rows, string $separator = "\t", string $null_as = "\\\\N"): bool {}

@Girgias
Copy link
Member

Girgias commented Oct 1, 2024

The changes will need to be applied to #15893

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSTM

@devnexen devnexen closed this in e609a21 Oct 1, 2024
devnexen added a commit to devnexen/php-src that referenced this pull request Oct 1, 2024
devnexen added a commit to devnexen/php-src that referenced this pull request Oct 1, 2024
jorgsowa pushed a commit to jorgsowa/php-src that referenced this pull request Oct 1, 2024
inspired from the Pdo\Pgsql new feature phpGH-15893.

close phpGH-16124
jorgsowa pushed a commit to jorgsowa/php-src that referenced this pull request Oct 1, 2024
inspired from the Pdo\Pgsql new feature phpGH-15893.

close phpGH-16124
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants